﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace BlogSite.Models
{
    public static class BlogHelper
    {
        public static int BlogID = 0;
        public static int CommentID = 0;

        public static List<Blog> Blogs = new List<Blog>();
        public static List<Comment> Comments = new List<Comment>();

        public static BlogCommentsViewModel GetBlogComments(int blogid)
        {
            BlogCommentsViewModel retval = new BlogCommentsViewModel();
            retval.Blog = Blogs.Where(b => b.BlogId == blogid).FirstOrDefault();
            if (retval.Blog != null)
            {
                List<Comment> comm = new List<Comment>();
                try
                {
                    comm.AddRange(Comments.Where(c => c.BlogId == blogid).OrderBy(c => c.CommentId).ToList());
                }
                catch {}
                retval.Comments = comm;
                return retval;
            }
            return null;
        }
    }
}